<?php
   class Giftphoto extends AppModel {
        var $alias  =   'Giftphoto';
        var $name = 'Giftphoto';
        var $useTable = 'gift_images';
        
        function delete($id = null, $cascade = true) {
            App::import('Component', 'Upload');
            $this->id   =   $id;
            $upload =   new UploadComponent();

            //delete thumbnail
            $thumbnail    =   $this->field('images');
            if (is_file(Configure::read('gift_gallery_thumb_absolute_path') . $thumbnail) && $thumbnail != 'no_image.gif') {
                $upload->delete(Configure::read('gift_gallery_thumb_absolute_path') . $thumbnail);
            }

            parent::delete($id, $cascade);
        }
        function paginateCount($conditions = null, $recursive = 0, $extra = array()) {
            $parameters = compact('conditions');
            $this->recursive = $recursive;
            $count = $this->find('count', array_merge($parameters, $extra));
            if (isset($extra['group'])) {
                $count = $this->getAffectedRows();
            }
            return $count;
        }
    }


?>
